<?php 

require_once "lib/GRS.php";

$grs = new GRS();

$game_id = $grs->params("game_id");
$mode_id = $grs->params("mode_id");

?>

<link href="css/style.css" type='text/css' rel='stylesheet' media='screen' />
<!-- ---------------------------------- GAMES --------------------------------------------------- -->
<?php if($grs->params('show') == 'games'):?>
    <?php $games = $grs->getGames(); ?>
    <div class='game_list'>
    <?php if($games):?> 
    <ul>
        <?php foreach ($games as $game):?>
        <li>
            <a href="javascript:showModes(<?php echo $game->id?>)">
                <img width="100" height="60" 
                     src="img/<?php echo $game->image ? $game->image : 'game_no_found.gif' ?>" 
                     title="<?php echo $game->name?>" alt="<?php echo $game->name ?>"/>
            </a>
		</li>
        <?php endforeach ?>
    </ul>
    <?php else: ?>
        <p>No existe Juegos en la base de datos</p>
    <?php endif ?>
    </div>
 <!-- ---------------------------------- MODES --------------------------------------------------- -->   
<?php elseif($grs->params('show') == 'modes'):?>
    <?php $modes = $grs->getModesWithRec($game_id); ?>
    <div class='mode_list'>
    <?php if($modes):?> 
        <ul>
            <li><a href="<?php echo $grs->url(null, array('game_id' => $game_id, 'mode_id' => 'all')); ?>">Todos</a></li>
            <?php foreach ($modes as $mode):?>
            <li>
				<a href="<?php echo $grs->url(null, array('game_id' => $game_id, 'mode_id' => $mode->id)); ?>">
                    <?php echo htmlspecialchars($mode->name)?>
                </a>
            </li>
            <?php endforeach ?>
        </ul>
    <?php else: ?>
        <p>No existe Modos en la base de datos</p>
    <?php endif ?>
    </div>
<?php endif?>
